﻿using System;
using System.Windows;
using System.Collections.Generic;
using FireFly;
using System.Collections;

namespace XAMLStylePad.ViewModels.TriggersAndSetters
{
    public class SetterViewModel : XamlViewModelBase<Setter>, ISetterViewModel
    {
        public SetterViewModel(Setter setter)
            : base(setter)
        {
        }

        #region Property
        public DependencyProperty Property
        {
            get
            {
                return Model != null ? Model.Property : null;
            }
            set
            {
                if(Model is Setter)
                {
                    Model.Property = value;
                    OnPropertyChanged("Property");
                }
            }
        }
        #endregion

        #region Value
        public object Value
        {
            get
            {
                return Model != null ? Model.Value : null;
            }
            set
            {
                if(Model is Setter)
                {
                    (Model as Setter).Value = value;
                    OnPropertyChanged("Value");
                }
            }
        }
        #endregion

        #region overrides

        public override string DisplayName
        {
            get
            {
                return string.Format("{0} = {1}", Property != null ? Property.Name : "<null>", Value);
            }
        }
        #endregion


        public override ICollection VisualChildren
        {
            get
            {
                return null;
            }
        }
    }
}